﻿using System;
using Core.Library;
using DataObject;
using DataObject.Article;
using DataObject.Category;

public partial class Controls_Article_Detail : System.Web.UI.UserControl
{
    protected int ArticleId;    
    protected string Title = string.Empty;
    protected string Body  = string.Empty;
    protected string Source = string.Empty;    
    protected string CategoryName = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        ArticleId = Utils.GetIdFromRequestString(Utils.ArticleId, 0);

        if (ArticleId > 0)
        {
            ArticleDetail();
        }
    }

    public void ArticleDetail()
    {
        var o = ArticleController.Article_GetById(ArticleId);
        if (o != null)
        {
            Title = o.Title;
            Body = o.Body;
            Source = o.Source;
            CategoryName = CategoryController.GetCategoryName(o.CategoryId);
            var imgHref = string.Format("{0}/Thumb.ashx?Id={1}&tId={2}&Size=670", Constants.ThumbImage, o.ArticleId, (int)CategoryType.Article);
            ltImage.Text = string.Format("<img src=\"{1}\" alt=\"\"  />", "", imgHref);
            Page.Title = string.Format(".: {0} {1} :.", o.Title, Constants.SITE_TITLE);
        }
    }
}